package com.cangshukj.web.controller.junong;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cangshukj.common.annotation.Log;
import com.cangshukj.common.core.controller.BaseController;
import com.cangshukj.common.core.domain.AjaxResult;
import com.cangshukj.common.enums.BusinessType;
import com.cangshukj.junong.domain.AgencyType;
import com.cangshukj.junong.service.IAgencyTypeService;
import com.cangshukj.common.utils.poi.ExcelUtil;
import com.cangshukj.common.core.page.TableDataInfo;

/**
 * 代理服务分类Controller
 * 
 * @author wangjie
 * @date 2025-04-01
 */
@Api(value = "/agency/type",description = "代理服务分类")
@RestController
@RequestMapping("/agency/type")
public class AgencyTypeController extends BaseController
{
    @Autowired
    private IAgencyTypeService agencyTypeService;

    /**
     * 查询代理服务分类列表
     */
    @ApiOperation("查询代理服务分类列表")
    @PreAuthorize("@ss.hasPermi('agency:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(AgencyType agencyType)
    {
        startPage();
        List<AgencyType> list = agencyTypeService.selectAgencyTypeList(agencyType);
        clearPage();
        return getDataTable(list);
    }

    @ApiOperation("查询代理服务分类列表不分页")
    @GetMapping("/listNoPage")
    public AjaxResult listNoPage(AgencyType agencyType)
    {
        List<AgencyType> list = agencyTypeService.selectAgencyTypeList(agencyType);
        return AjaxResult.success(list);
    }

    /**
     * 获取代理服务分类详细信息
     */
    @ApiOperation("获取代理服务分类详细信息")
    @PreAuthorize("@ss.hasPermi('agency:type:query')")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") String typeId)
    {
        return AjaxResult.success(agencyTypeService.selectAgencyTypeByTypeId(typeId));
    }

    /**
     * 新增代理服务分类
     */
    @ApiOperation("新增代理服务分类")
    @PreAuthorize("@ss.hasPermi('agency:type:add')")
    @Log(title = "代理服务分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AgencyType agencyType)
    {
        agencyType.setCreateBy(getUsername());
        agencyType.setCreateTime(new Date());
        return toAjax(agencyTypeService.insertAgencyType(agencyType));
    }

    /**
     * 修改代理服务分类
     */
    @ApiOperation("修改代理服务分类")
    @PreAuthorize("@ss.hasPermi('agency:type:edit')")
    @Log(title = "代理服务分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AgencyType agencyType)
    {
        agencyType.setUpdateBy(getUsername());
        agencyType.setUpdateTime(new Date());
        return toAjax(agencyTypeService.updateAgencyType(agencyType));
    }

    /**
     * 删除代理服务分类
     */
    @ApiOperation(" 删除代理服务分类")
    @PreAuthorize("@ss.hasPermi('agency:type:remove')")
    @Log(title = "代理服务分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable String[] typeIds)
    {
        return toAjax(agencyTypeService.deleteAgencyTypeByTypeIds(typeIds));
    }
}
